var typeLib = require('../type')
var pathLib = require('path')
var filter = require('arr-filter')




/**
 * [arrayFilter description]
 * @param  {[type]}   arr      [description]
 * @param  {Function} callback [description]
 * @return {[type]}            [description]
 */
function arrayFilter(arr, callback, thisArg) {
	if(!Array.isArray(arr)){
		// throw new TypeError('Excepts an array as the first argument')
	}

	// callback must be function 

	var result = []
	for (var i = 0; i < arr.length; i++) {
		if(callback.call(thisArg, arr[i], i, arr)) result.push(arr[i])
	}

	return result
}

var array = ['a', {a: 'b'}, 1, 'b', 2, {c: 'd'}, 'c']
var callback = function(ele) {
	return typeof ele === 'string';
}

console.group('arr-filter')
console.log( filter(array, callback) );
console.groupEnd()

console.log('\n-----------------------\n')

console.group(pathLib.basename(__filename))
console.log( arrayFilter(array, callback) );
console.groupEnd()

